package com.rd.student.jike.class2.xuezhixin.day0731;

import java.util.ArrayList;
import java.util.Collections;

public class Work08 {

    // 自己实现shuffle

    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0;i<50;i++){
            list.add(i);
        }

        int len = list.size()-1;
        for (int i = len;i > 0;i--){
            int subscript = (int) (Math.random() * len);
            Collections.swap(list,i,subscript);
            len -= 1;
        }
        System.out.println(list);

        for (int i = 0;i<20;i++){
            System.out.println((i+1) + "\t" + list.get(i));
        }
    }
}
